local hengque = fk.CreateSkill{
  name = "wk_heg__hengque",
}

Fk:loadTranslationTable{
  ["wk_heg__hengque"] = "衡阙",
  [":wk_heg__hengque"] = "出牌阶段，你可以令一名角色摸一张牌，然后弃置一名与其势力相同的角色一张牌，若为同一角色或手牌数不相等，此技能本回合失效。",

  ["@@wk_heg__hengque-turn"] = "衡阙失效"
}

local HG = require "packages/new_heg_diy_my/util"
local H = require "packages/ol_hegemony/util"

hengque:addEffect("active", {
  anim_type = "control",
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected, selected_cards, card, extra_data)
    if #selected > 0 then return end
    return true
  end,
  feasible = function (self, player, selected, selected_cards, card)
    return #selected == 1
  end,
  on_use = function (self, room, effect)
    local to1 = effect.tos[1]
    local player = effect.from
    to1:drawCards(1, hengque.name)
    if player.dead then return end
    local to2s = table.filter(room:getAlivePlayers(false), function(p)
      return H.compareKingdomWith(p, to1) and not p:isNude()
    end)
    if #to2s == 0 then return end
    local to2 = room:askToChoosePlayers(player, {
      max_num = 1,
      min_num = 1,
      skill_name = hengque.name,
      targets = to2s,
      cancelable = false
    })
    to2 = to2[1]
    local c = room:askToChooseCard(player, {
      target = to2,
      flag = "he",
      skill_name = hengque.name
    })
    room:throwCard(c, hengque.name, to2, player)
    if player.dead then return end
    if to2 == to1 or to2:getHandcardNum() ~= to1:getHandcardNum() then
      room:invalidateSkill(player, hengque.name, "-turn")
      room:setPlayerMark(player, "@@wk_heg__hengque-turn", 1)
    end
  end
}
)

return hengque